// convertplugin.cpp : Implementation of CConvertPlugin

#include "stdafx.h"
#include "convertplugin.h"
#include "maindlg.h"


// CConvertPlugin

STDMETHODIMP CConvertPlugin::GetType(void)
{
	// TODO: Add your implementation code here

	return S_OK;
}

STDMETHODIMP CConvertPlugin::GetImage(VARIANT* varImage)
{
	// TODO: Add your implementation code here

	HRSRC hrsrc = ::FindResource(ATL::_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDB_PNG1), _T("PNG"));
	if ( hrsrc != NULL )
	{
		DWORD dwSize = ::SizeofResource(ATL::_AtlBaseModule.GetResourceInstance(), hrsrc);
		HGLOBAL hglb = ::LoadResource(ATL::_AtlBaseModule.GetResourceInstance(), hrsrc);

		if (hglb != NULL)
		{
			LPBYTE pData = (LPBYTE)::LockResource(hglb);
			if (pData != NULL)
			{
				BSTR pBuf = SysAllocStringByteLen(NULL, dwSize);
				memcpy((char *)pBuf, pData, dwSize);
				varImage->bstrVal = pBuf;
				varImage->vt = VT_BSTR;

				UnlockResource(hglb);
				::FreeResource(hglb);

				return S_OK;
			}
		}
	}

	return E_FAIL;
}

STDMETHODIMP CConvertPlugin::ShowDialog(void)
{
	// TODO: Add your implementation code here

	CMainDlg dlg;
	dlg.DoModal();

	return S_OK;
}
